import React, { useState } from "react";
//JSX高频场景-复杂条件渲染
//自定义函数 + 判断语句
function App() {
  const [type, setType] = useState(1); // 初始化 type 为 1

  const getArticle = () => {
    if (type === 0) {
      return <div>模板1</div>;
    } else if (type === 1) {
      return <div>模板2</div>;
    }
  };

  return (
    <>
      {getArticle()}
      <button onClick={() => setType(0)}>切换到模板1</button>
      <button onClick={() => setType(1)}>切换到模板2</button>
    </>
  );
}

export default App;
